CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

# Project name
PROJECT(edf)

SET(EXECUTABLE_OUTPUT_PATH 		${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH 	  	${PROJECT_BINARY_DIR}/lib)

# Directories
SET(DIR_root 		${PROJECT_SOURCE_DIR})
SET(DIR_edf 		${DIR_root}/)
SET(DIR_tinyxml 	${DIR_root}/tinyxml)

# Config the CMake's C/CXX/SHARED/MOUDLE Flags 
# Linux
IF(UNIX)
INCLUDE_DIRECTORIES(	${DIR_tinyxml})
LINK_DIRECTORIES(		${DIR_tinyxml})
SET(ADD_CFLAGS 		"-m32 -fpic -Wall -Wno-missing-braces  -Wmissing-declarations -Wmissing-prototypes -D_TARGET_OS=_OS_GNU -D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1")
SET(ADD_LDFLAGS 	"-lc -lrt -lm -lsqlite3 -lxml2 -lsctp -lpthread -lreadline -lncurses")
SET(ADD_DEBUG 		"-g")
SET(ADD_OPTIMIZE 	"")

# Windows
ELSEIF(WIN32)
INCLUDE_DIRECTORIES(	${DIR_tinyxml}	)
LINK_DIRECTORIES(		${DIR_tinyxml}
						${LIBRARY_OUTPUT_PATH}	)

SET(CMAKE_C_FLAGS_DEBUG "/MTd /Zi /D \"_CRT_NON_CONFORMING_SWPRINTFS\" /D \"_CRT_SECURE_NO_WARNINGS\" ")
SET(CMAKE_C_FLAGS_RELEASE "/MT /D \"_CRT_NON_CONFORMING_SWPRINTFS\" /D \"_CRT_SECURE_NO_WARNINGS\"  ")
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi /D \"_CRT_NON_CONFORMING_SWPRINTFS\" /D \"_CRT_SECURE_NO_WARNINGS\"  ")
SET(CMAKE_CXX_FLAGS_RELEASE "/MT /D \"_CRT_NON_CONFORMING_SWPRINTFS\" /D \"_CRT_SECURE_NO_WARNINGS\"  ")

# Unicode Support 
ADD_DEFINITIONS(-DUNICODE -D_UNICODE -D_TARGET_OS=_OS_WIN)
					
# Debug/Release 					
IF(CMAKE_CFG_INTDIR MATCHES "Debug")					
SET(ADD_LDFLAGS 	"/LIBPATH:${DIR_root}/lib/debug")				
ELSE(CMAKE_CFG_INTDIR MATCHES "Debug")
SET(ADD_LDFLAGS 	"/LIBPATH:${DIR_root}/lib/release")				
ENDIF(CMAKE_CFG_INTDIR MATCHES "Debug")				
					
SET(ADD_CFLAGS 		"")
SET(ADD_LDFLAGS 	"")
SET(ADD_DEBUG 		"")
SET(ADD_OPTIMIZE 	"")
SET(ADD_LIBS 		"")

ENDIF()


SET(CMAKE_C_FLAGS 				"${ADD_CFLAGS} ${ADD_DEBUG} ${ADD_OPTIMIZE} ${CMAKE_C_FLAGS}")
SET(CMAKE_CXX_FLAGS 			"${ADD_CFLAGS} ${ADD_DEBUG} ${ADD_OPTIMIZE} ${CMAKE_CXX_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS 	"${ADD_LDFLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS 	"${ADD_LDFLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")

# Definition
# ADD_DEFINITIONS()


#INCLUDE & SOURCE
SET(edf_SRC 		${DIR_edf}/edf_types.h
					${DIR_edf}/edf_gen.cpp
	)

ADD_EXECUTABLE(edf_gen 			${edf_SRC})
TARGET_LINK_LIBRARIES(edf_gen 	tinyxml_STL)


